{layout name="layout" /}
<h4 class="h4"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;添加商品</h4>
<form class="layui-form" action="updatashopp" name="editForm" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$data.id}">
    <div class="layui-form-item">
        <label class="layui-form-label"  style="width:100px;">商品名字</label>
        <div class="layui-input-block">
            <input type="text" name="title" required lay-verify="username" placeholder="商品名字" autocomplete="off" class="layui-input" value="{$data.title}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"  style="width:100px;">商品价格</label>
        <div class="layui-input-block">
            <input type="number" name="price"  placeholder="请输入商品价格" autocomplete="off" class="layui-input" value="{$data.price}">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label" style="width:100px;">输入介绍</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" name="text" >{$data.text}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    
</form>
<style>
    .file {
        display: flex;
        justify-content: center;
    }
</style>
<script>
    //Demo
    layui.use('form', function () {
        var form = layui.form;

        // form.verify({
        //     username: function (value, item) { //value：表单的值、item：表单的DOM对象
        //         if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
        //             return '用户名不能有特殊字符';
        //         }
        //         if (/(^\_)|(\__)|(\_+$)/.test(value)) {
        //             return '用户名首尾不能出现下划线\'_\'';
        //         }
        //         if (/^\d+\d+\d$/.test(value)) {
        //             return '用户名不能全为数字';
        //         }
        //     }

        // });
    });
    $(".newspic").click(function () {
        $(this).next('input').click();
    });
    function showPic(data) {
        if (data.files && data.files[0]) {
            var reader = new FileReader();
            reader.readAsDataURL(data.files[0]);
            reader.onload = function (evt) {
                data.parentNode.childNodes[1].childNodes[1].src = evt.target.result;
            }
        }
    }

</script>